package com.immunology.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.immunology.model.DataSource;

public class ConnectionManager {
	private DataSource dataSource;

	public Connection getConnection() {
		dataSource = new DataSource();
		Connection connection = null;
		try {
			Class.forName(dataSource.getDriverName()).newInstance();
			connection = DriverManager.getConnection(
					dataSource.getDataBaseUrl(), dataSource.getUser(),
					dataSource.getPassword());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return connection;
	}

	public void closeConnection(Connection connection) {
		try {
			connection.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
